<template>
  <div>
    <link rel="stylesheet" href="https://yun.5tree.cn/shijiwxy/webV2/css/ggui.css" />
    <!-- <link rel="stylesheet" href="/assets/seal.css" /> -->
    <el-tabs ref="tab11111" v-model="activeName" id="topWrap" type="border-card" @tab-click="handleClick">
      <div class="categoryTxt">
        <li id="templateSet" class="cateParentLi" style=""><a :class="activeName=='tabs1Flag'?'cateParentALL':'cateParentA'"  href="#x41">评价计划</a></li>
        <li v-if='isAdmin==1' id="hardwareDetail" class="cateParentLi" style=""><a :class="activeName=='tabs4Flag'?'cateParentALL':'cateParentA'"  href="#x44">评价模版</a></li>
        <li v-if='isAdmin==1' id="log" class="cateParentLi" style=""><a :class="activeName=='tabs6Flag'?'cateParentALL':'cateParentA'"  href="#x46">操作日志</a></li>
      </div>
      <div class="subCrumbs"><i class="fa fa-home fa-fw"></i> 当前位置：<span><a href="#"
            id="toIndex">首页<em></em></a></span>/<span>智慧评价</span>/<span>
          <a href="javascript:;">{{ nowName }}<em></em></a></span>
        <span v-if="isDetail" style="padding:0;">/<span><a href="javascript:;">{{level2Text}}<em></em></a></span></span>
      </div>
      <tabs1 v-if="tabsArr.tabs1Flag"></tabs1>
      <tabs2 v-if="tabsArr.tabs2Flag"></tabs2>
      <tabs3 v-if="tabsArr.tabs3Flag"></tabs3>
      <tabs4 v-if="tabsArr.tabs4Flag"></tabs4>
      <tabs5 v-if="tabsArr.tabs5Flag"></tabs5>
      <tabs6 v-if="tabsArr.tabs6Flag"></tabs6>
    </el-tabs>
  </div>
</template>
<script>
// 计划列表
import tabs1 from './view/list.vue'
// // 添加计划
import tabs2 from './view/add_plan.vue'
// // 添加统计
import tabs3 from './view/statistics.vue'
// // 模版列表
import tabs4 from './view/tem_list.vue'
// 添加模版
import tabs5 from './view/add.vue'
// 日志
import tabs6 from './view/log.vue'

// import tabs3 from './view/inbox'
export default {
  components: { tabs1, tabs2, tabs3, tabs4, tabs5, tabs6 },
  data () {
    return {
      activeName: 'tabs1Flag',
      nowName: '评价计划',
      level2Text: '',
      isAdmin: 0,
      tabsArr: {
        tabs1Flag: true,
        tabs2Flag: false,
        tabs3Flag: false,
        tabs4Flag: false,
        tabs5Flag: false,
        tabs6Flag: false
      },
      all: ['评价计划', '新建计划', '计划统计', '模版列表', '评价模版', '操作日志'],
      allHash: ['#x41', '#x42', '#x43', '#x44', '#x45', '#x46'],
      isDetail: false,
      editPlan: null,
      editTemplate: null
    }
  },
  created () {
    // 默认显示标签 缓存方便刷新
    if (sessionStorage.tabsArr !== undefined) {
      this.tabsArr = JSON.parse(sessionStorage.tabsArr)
      for (var key in this.tabsArr) {
        if (this.tabsArr[key]) {
          this.activeName = key
        }
      }
    }

    // 判断是否是管理员
    // 超级管理员，智慧评价管理员
    var adminArray = sessionStorage.rlids.split(',')
    if (sessionStorage.identity === '99' || adminArray.includes('56')) {
      this.isAdmin = 1
    } else {
      this.isAdmin = 0
      // 判断是否是班主任
      let mapBZRs = JSON.parse(sessionStorage.getItem('mapBZR'))
      if (mapBZRs.length > 0) {
        this.isBzr = true
      } else {
        this.isBzr = false
      }
    }
    // 计划列表
    const nowTab=this.allHash.indexOf(window.location.hash.split('?')[0])+1
    this.change(nowTab)
  },
  methods: {
    // tabs的切换点击方法 tab中的name是当前点击选中的那一项的name的值
    handleClick (tab) {
      if (this.nowName === tab.label) {
        return false
      }
      this.nowName = tab.label
      for (var key in this.tabsArr) {
        if (tab.name !== key) {
          this.tabsArr[key] = false
        } else {
          this.tabsArr[key] = true
        }
      }
      this.isDetail = false
      sessionStorage.tabsArr = JSON.stringify(this.tabsArr)
    },
    tabClick (tabIndex) {
      this.change(tabIndex)
    },
    change(current) {
      for (let x=1; x<7; x++) {
          this.tabsArr['tabs'+x+'Flag'] = current === x
      }
      if (current<=3) {
         this.activeName='tabs1Flag'
          this.nowName='计划列表'
          if (current===2||current===3) {
            this.isDetail=true
            this.level2Text = current===3?'计划统计':sessionStorage.level2Text
          } else {
            this.isDetail=false
          }
      } else if (current===6) {
        this.activeName='tabs6Flag'
          this.nowName='操作日志'
      } else {
          this.activeName='tabs4Flag'
          this.nowName='模版列表'
          if (current===5) {
            this.isDetail=true
            this.editTemplate=sessionStorage.editTemplate
            this.level2Text = sessionStorage.level2Text
          } else {
            this.isDetail=false
          }
      }
    }
  }
}
</script>
<style>
#app {
  font-family: Helvetica, sans-serif;
  text-align: center;
}

.el-tabs__nav-wrap:after {
  background: none;
}

.el-tabs--border-card>.el-tabs__content {
  padding: 0;
}

.el-tabs__nav {
  float: none;
}

.el-tabs__nav-scroll {
  text-align: center;
  padding: 12px 0 10px 0;
  background: #dbe3ed;
  border-bottom: 1px #cbd6e4 solid;
}

.el-tabs--border-card>.el-tabs__header .el-tabs__item {
  width: 120px;
  line-height: 36px;
  text-align: center;
  background: #fff;
  color: #666666;
  margin-right: 5px;
  box-shadow: 0px 1px 1px rgba(134, 145, 155, 0.42);
}

/* 上级菜单 */
.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active {
  background: #5D5DEF;
  color: #fff;
  width: 120px;
  line-height: 36px;
}

.el-tabs--border-card>.el-tabs__header .el-tabs__item:not(.is-disabled):hover {
  color: #fff;
}

.el-tabs--border-card>.el-tabs__header .el-tabs__item:not(.is-active):hover {
  background: #00ccff;
  color: #fff;
}

/* 表格无下划线阴影 */
.el-tabs--border-card {
  background: none;
  border: none;
  box-shadow: none;
}
table.el-table__header,.el-table__body {
  font-size: 14px;
}
.el-table .el-table__cell {
  padding: 6px 0;
}
.el-table tr.tr-grey {
  background: #f9f9f9;
  color: #b1b1b1;
}
/* 输入框 */
.el-input__inner {
  height: 30px;
  line-height: 30px;
}

/* 按钮 */
.el-button {
  padding: 8px 20px;
}

/* 表头颜色 */
.el-table th.el-table__cell {
  color: #5a728a;
  background-color: #f7f7f7;
}

.el-pagination {
  padding: 2px 17px;
}

.el-tabs__header.is-top {
  display: none;
}
.el-form-item__label {line-height: 30px;}
.search {
  height: auto;
}
.el-table__empty-block {
  max-height: 72px;
}
*::-webkit-scrollbar {
  width: 5px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  opacity: 0.2;
  background:#ccc;
}
*::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
}
.el-message-box{
  width: 360px;
}
.el-button + .el-button{
  margin-left:3px;
}
/* 日期 */
.el-date-table td.end-date span, .el-date-table td.start-date span {
  background-color: #5d5def;
}
.el-date-table td.available:hover {
    color: #5d5df9;
}
.el-table .warning-row {
  background: oldlace;
}
.categoryTxt li{
  margin-right: 4px;
}
.el-image-viewer__btn{
  padding: 5px 7px;
}
</style>
